package com.xuecheng.content.api;

import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("师资管理接口")
@RestController
@RequestMapping("/courseTeacher")
@RequiredArgsConstructor
public class CourseTeacherController {

   private final CourseTeacherService courseTeacherService;

    @GetMapping("/list/{courseId}")
    @ApiOperation("查询教师接口")
    public List<CourseTeacher> getCourseTeacher(@PathVariable("courseId") @Validated Long courseId){
        return courseTeacherService.getByCourseId(courseId);
    }

    @PostMapping
    @ApiOperation("添加教师")
    public CourseTeacher saveCourseTeach(@RequestBody @Validated CourseTeacher courseTeacher){
        Long companyId = 1232141425L;
        return courseTeacherService.saveCourseTeach(courseTeacher,companyId);
    }

    @PutMapping
    @ApiOperation("修改教师")
    public CourseTeacher updateCourseTeach(@RequestBody @Validated CourseTeacher courseTeacher){
        //1232141425
                        //1232141425
        Long companyId = 1232141425L;
        return courseTeacherService.saveCourseTeach(courseTeacher,companyId);
    }

    @DeleteMapping("/course/{courseId}/{id}")
    @ApiOperation("删除教师")
    public void deleteCourseTeacher(@PathVariable Long courseId,@PathVariable("id") Long id){
        Long companyId = 1232141425L;
        courseTeacherService.deleteCourseTeacher(courseId,id,companyId);

    }
}
